<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>数据上报</title>
    <script type="text/javascript" src="../../script/aes.js"></script>
	<script type="text/javascript" charset="UTF-8" src="../../script/naes.js"></script>
	<script type="text/javascript" src="../../script/modeecb.js"></script>
    <script type="text/javascript" src="../../script/tmd5.js"></script>
    <script type="text/javascript" src="../../script/constants.js"></script>
    <script type="text/javascript" src="../../resource/jquery214.js"></script>
    <script type="text/javascript" src="../../script/api.js"></script>
    <style>
    	body{
    	    margin: 0;	
    	    background:url(../../image/bj.png) repeat-x 0;
    	    background-size: 100%;
    	}
    	.title{
    	    height: 45px;
    	    background: #0483d3;
    	    color: #ffffff;
    	    line-height: 45px;
    	    font-size: 20px;
    	    margin-bottom: 20px;
    	}
        .book{
            width: 100%;
            background: #ffffff;
            border-bottom: #e0e0e0 1px solid;
            border-top: #e0e0e0 1px solid;
            display: table;padding: 10px;
            height: 100px;
        }
        .imgdiv{
            width: 100%;
            height: 80px;
            display:table-cell;
            vertical-align:middle;
        }
        .book_text{
            text-align: center;
            color: #666666;
            width: 90%;
            height: 80px;
            line-height: 80px;
            background: #fff;
            margin: 0 auto;
        }
    </style>
</head>
<body>
<header id="statusBar">
  <div class="title">
    <div style="float: left;width: 30px;height: 30px;padding: 7.5px;" onclick="api.closeWin();">
    <img src="../../image/hotelManage/back.png"  style="width: 100%;"/>
    </div>
    <div style="float: left;color: #ffffff;">
    数据上报
    </div>
    <div style="float: right;color: #32CD32;margin-right: 20px;" onclick="submit();">
    上传
    </div>
  </div>
  </header>
  <div id="cus_info">
    
  </div>
</body>
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript">
	apiready = function(){
	    
	    if(api.systemType == "ios"){
		   document.getElementById("statusBar").style.background = "#298cb4";
		}
	    $api.fixStatusBar( $api.dom('header') );
	    
	    var cusInfo = $api.getStorage("cusInfo");
	    if(cusInfo.length > 0){
	        html = "";
		    for(var i=0;i<cusInfo.length;i++){
		      html += "<div class=\"book\">"
	            +"<div style=\"float: left;height: 80%;\">"
	            + "<div>姓名："+cusInfo[i].name+"</div>"
		        + "<div>证件号码："+cusInfo[i].idnum+"</div>"
		        + "<div>房间号："+cusInfo[i].room+"</div>"
		        + "<div>入住时间："+cusInfo[i].ruzhushijian+"</div>"
		        + "</div>"
		        + "<div style=\"float: right;width: 20%;height: 80px;padding-right: 20px;\" onclick=\"\">"
		        + "<div class=\"imgdiv\">"
		        + "<img src=\""+cusInfo[i].img+"\" style=\"width: 60%;vertical-align: middle;\"/>"
		        + "</div></div></div>";
		    }
	    }else{
            html = "<div class=\"book_text\">暂无未上传数据</div>";
        }
        $("#cus_info").html(html);
	};

    //数据上传
    function submit(){
        var cusInfo = $api.getStorage("cusInfo");
        if(cusInfo.length>0){
          upload(0);
        }
    }
    
    function upload(param){
        var link = "http://www.scscpt.com:9080/JDSJD_CS_Server/BookRoomServlet";
        var cusInfo = $api.getStorage("cusInfo");
        var newArr = new Array();
        if(param<cusInfo.length){
           api.ajax({
		        url: link,
		        method: 'post',
		        data: { 
			            values: cusInfo[param]
			        },
			    dataType: 'text'
	        },function(ret,err){
		        if(ret && ret == "1"){
		           cusInfo[param].isupload = 1;
		        }else{
		           newArr.push(cusInfo[j]);
		        }
		        if(param == cusInfo.length-1){
		           $api.setStorage("cusInfo",newArr);
			       api.sendEvent({
				       name: 'dataSubmit'
				   });
				   location.reload();
		        }else{
		           upload(param+1);
		        }
	        });
	    }    
    }
</script>
</html>